﻿<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net"
         xmlns:db="http://www.springframework.net/database">
  <object type="Spring.Objects.Factory.Config.PropertyPlaceholderConfigurer, Spring.Core">
    <property name="ConfigSections" value="databaseSettings"/>
  </object>

  <db:provider id="DbProvider" provider="SqlServer-2.0" 
               connectionString="Server=${db.datasource};database=${db.database};uid=${db.user};pwd=${db.password};"/>

  <object id="NHibernateSessionFactory" type="Spring.Data.NHibernate.LocalSessionFactoryObject, Spring.Data.NHibernate32">
    <property name="DbProvider" ref="DbProvider"/>
    <property name="MappingAssemblies">
      <list>
        <value>BigMouse.Model</value>
      </list>
    </property>
    <property name="HibernateProperties">
      <dictionary>
        <entry key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider"/>
        <entry key="dialect" value="NHibernate.Dialect.MsSql2005Dialect"/>
        <entry key="hibernate.connection.driver_class" value="NHibernate.Driver.SqlClientDriver"/>
        <entry key="show_sql" value="false"/>
        <entry key="adonet.batch_size" value="10"/>
        <entry key="command_timeout" value="60"/>
        <!--显式启用二级缓存-->
        <entry key="cache.use_second_level_cache" value="true"/>
        <entry key="cache.use_query_cache" value="true"/>
        <entry key="cache.provider_class" value="NHibernate.Cache.HashtableCacheProvider"/>
      </dictionary>
    </property>
    <property name="ExposeTransactionAwareSessionFactory" value="true" />
  </object>

  <object id="HibernateTemplate" type="Spring.Data.NHibernate.Generic.HibernateTemplate">
    <property name="SessionFactory" ref="NHibernateSessionFactory" />
    <property name="TemplateFlushMode" value="Auto" />
    <property name="CacheQueries" value="true" />
  </object>

</objects>